package com.myk.game.gobangchess.rooms;

import com.myk.game.gobangchess.*;
import com.myk.game.gobangchess.ai.shock.P4_Engine;
import com.myk.game.gobangchess.ai.startzone.StarZoneEngine;
import com.myk.game.gobangchess.constants.BoardStyleData;
import com.myk.game.gobangchess.constants.WinMode;
import com.myk.game.gobangchess.rooms.absrooms.AbsAiRoom;
import com.myk.game.gobangchess.signs.*;
import com.myk.game.gobangchess.utils.GridsUtils;
import com.myk.game.gobangchess.utils.Pair;

import java.util.ArrayList;
import java.util.List;

/**
 * 星域 Ai房
 */
public class StarsZoneAiRoom extends AbsAiRoom {

    private int curMode = 0;

    private int neutralState = 0;
    private boolean[][] situation = new boolean[2][16];

    private static final int BLACK_CUR = 1;
    private static final int WHITE_CUR = 2;
    private Rule rule = new Rule0();

    //    private boolean noClock = true;
    private boolean isNeutral;

    private int redNum = 16;
    private int blueNum = 16;
    private int blackNeutralNum;
    private int whiteNeutralNum;
    private List<int[]> lastPoint = new ArrayList<int[]>();

    int[][] banPosition =
            {{0, 0, 0, 1, 1, 0, 0, 0, 0},
                    {0, 0, 1, 1, 1, 1, 1, 1, 0},
                    {0, 1, 1, 1, 1, 1, 1, 1, 0},
                    {1, 1, 1, 1, 1, 1, 1, 1, 0},
                    {1, 1, 1, 1, 1, 1, 1, 1, 1},
                    {0, 1, 1, 1, 1, 1, 1, 1, 1},
                    {0, 1, 1, 1, 1, 1, 1, 1, 0},
                    {0, 1, 1, 1, 1, 1, 1, 0, 0},
                    {0, 0, 0, 0, 1, 1, 0, 0, 0}};

    private interface Rule {
        void reset();

        //        void doRule(int row, int col, int value);
        void getScore();

    }

    @Override
    public String getGameInfo() {
        signList.clear();
        List<Sign> tmpSignList = new ArrayList<>();
        if (!lastPoint.isEmpty()) {

            for (int i = 0; i < lastPoint.size(); i++) {
                tmpSignList.add(new AroundSign(getIndex((lastPoint.get(i))[0], (lastPoint.get(i))[1]), "#00000000", "#FF00FF00", 1f));

            }
        }
        updateBoard(tmpSignList);
        rule.getScore();
        signList.add(new TitleSign(0.05f, 0.05f, 0, blackNeutralNum + "", "#FFAAFF00", 0.6f));
        signList.add(new TitleSign(0.95f, 0.05f, 0, whiteNeutralNum + "", "#FFAAFF00", 0.6f));
        signList.add(new TitleSign(0.05f, 0.95f, 0, redNum + "", "#FFAAFF00", 0.6f));
        signList.add(new TitleSign(0.95f, 0.95f, 0, blueNum + "", "#FFAAFF00", 0.6f));
        return super.getGameInfo();
    }

    @Override
    public String getCoordMode() {
        return "33000000";
    }

    private class Rule0 implements Rule {

        @Override
        public void reset() {
//            originGrids = GridsUtils.createEmptyGrids(9, 9);
//            curGrids = GridsUtils.copyGrids(originGrids);
            curGrids[4][4] = 2;
            signList.clear();
            updateBoard(new ArrayList<>());
            blackNeutralNum = isCurMode("比赛") ? 8 : 7;
            whiteNeutralNum = isCurMode("比赛") ? 8 : 7;
            blackScore = 0;
            whiteScore = 0;
        }

        @Override
        public void getScore() {
            situation = new boolean[2][16];
            boolean[][] isRepeat = new boolean[2][16];
            for (int i = 0; i < curGrids.length; i++) {
                for (int j = 0; j < curGrids[0].length; j++) {
                    int[] dir = {0, 0, 0, 0};
                    if (curGrids[i][j] == 3) {
                        //左方
                        for (int x = j - 1; x >= 0; x--) {
                            if (curGrids[i][x] == 3) {
                                dir[0] = 1;
                                break;
                            }
                        }

                        // 上方
                        for (int y = i - 1; y >= 0; y--) {
                            if (curGrids[y][j] == 3) {
                                dir[1] = 1;
                                break;
                            }
                        }

                        // 下方
                        for (int y = i + 1; y < curGrids.length; y++) {
                            if (curGrids[y][j] == 3) {
                                dir[2] = 1;
                                break;
                            }
                        }

                        // 右方
                        for (int x = j + 1; x < curGrids[i].length; x++) {
                            if (curGrids[i][x] == 3) {
                                dir[3] = 1;
                                break;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0 && dir[3] == 0) {
                            situation[0][0] = true;
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0 && dir[3] == 1) {
                            if (situation[0][1]) {
                                isRepeat[0][1] = true;
                            }
                            else {
                                situation[0][1] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1 && dir[3] == 0) {
                            if (situation[0][2]) {
                                isRepeat[0][2] = true;
                            }
                            else {
                                situation[0][2] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1 && dir[3] == 1) {
                            if (situation[0][3]) {
                                isRepeat[0][3] = true;
                            }
                            else {
                                situation[0][3] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0 && dir[3] == 0) {
                            if (situation[0][4]) {
                                isRepeat[0][4] = true;
                            }
                            else {
                                situation[0][4] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0 && dir[3] == 1) {
                            if (situation[0][5]) {
                                isRepeat[0][5] = true;
                            }
                            else {
                                situation[0][5] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 1 && dir[3] == 0) {
                            if (situation[0][6]) {
                                isRepeat[0][6] = true;
                            }
                            else {
                                situation[0][6] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 1 && dir[3] == 1) {
                            if (situation[0][7]) {
                                isRepeat[0][7] = true;
                            }
                            else {
                                situation[0][7] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0 && dir[3] == 0) {
                            if (situation[0][8]) {
                                isRepeat[0][8] = true;
                            }
                            else {
                                situation[0][8] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0 && dir[3] == 1) {
                            if (situation[0][9]) {
                                isRepeat[0][9] = true;
                            }
                            else {
                                situation[0][9] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 1 && dir[3] == 0) {
                            if (situation[0][10]) {
                                isRepeat[0][10] = true;
                            }
                            else {
                                situation[0][10] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 1 && dir[3] == 1) {
                            if (situation[0][11]) {
                                isRepeat[0][11] = true;
                            }
                            else {
                                situation[0][11] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 0 && dir[3] == 0) {
                            if (situation[0][12]) {
                                isRepeat[0][12] = true;
                            }
                            else {
                                situation[0][12] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 0 && dir[3] == 1) {
                            if (situation[0][13]) {
                                isRepeat[0][13] = true;
                            }
                            else {
                                situation[0][13] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 1 && dir[3] == 0) {
                            if (situation[0][14]) {
                                isRepeat[0][14] = true;
                            }
                            else {
                                situation[0][14] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 1 && dir[3] == 1) {
                            if (situation[0][15]) {
                                isRepeat[0][15] = true;
                            }
                            else {
                                situation[0][15] = true;
                            }
                        }

                    }
                    if (curGrids[i][j] == 4) {
                        //左方
                        for (int x = j - 1; x >= 0; x--) {
                            if (curGrids[i][x] == 4) {
                                dir[0] = 1;
                                break;
                            }
                        }

                        // 上方
                        for (int y = i - 1; y >= 0; y--) {
                            if (curGrids[y][j] == 4) {
                                dir[1] = 1;
                                break;
                            }
                        }

                        // 下方
                        for (int y = i + 1; y < curGrids.length; y++) {
                            if (curGrids[y][j] == 4) {
                                dir[2] = 1;
                                break;
                            }
                        }

                        // 右方
                        for (int x = j + 1; x < curGrids[i].length; x++) {
                            if (curGrids[i][x] == 4) {
                                dir[3] = 1;
                                break;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0 && dir[3] == 0) {
                            situation[1][0] = true;
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0 && dir[3] == 1) {
                            if (situation[1][1]) {
                                isRepeat[1][1] = true;
                            }
                            else {
                                situation[1][1] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1 && dir[3] == 0) {
                            if (situation[1][2]) {
                                isRepeat[1][2] = true;
                            }
                            else {
                                situation[1][2] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1 && dir[3] == 1) {
                            if (situation[1][3]) {
                                isRepeat[1][3] = true;
                            }
                            else {
                                situation[1][3] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0 && dir[3] == 0) {
                            if (situation[1][4]) {
                                isRepeat[1][4] = true;
                            }
                            else {
                                situation[1][4] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0 && dir[3] == 1) {
                            if (situation[1][5]) {
                                isRepeat[1][5] = true;
                            }
                            else {
                                situation[1][5] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 1 && dir[3] == 0) {
                            if (situation[1][6]) {
                                isRepeat[1][6] = true;
                            }
                            else {
                                situation[1][6] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 1 && dir[3] == 1) {
                            if (situation[1][7]) {
                                isRepeat[1][7] = true;
                            }
                            else {
                                situation[1][7] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0 && dir[3] == 0) {
                            if (situation[1][8]) {
                                isRepeat[1][8] = true;
                            }
                            else {
                                situation[1][8] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0 && dir[3] == 1) {
                            if (situation[1][9]) {
                                isRepeat[1][9] = true;
                            }
                            else {
                                situation[1][9] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 1 && dir[3] == 0) {
                            if (situation[1][10]) {
                                isRepeat[1][10] = true;
                            }
                            else {
                                situation[1][10] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 1 && dir[3] == 1) {
                            if (situation[1][11]) {
                                isRepeat[1][11] = true;
                            }
                            else {
                                situation[1][11] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 0 && dir[3] == 0) {
                            if (situation[1][12]) {
                                isRepeat[1][12] = true;
                            }
                            else {
                                situation[1][12] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 0 && dir[3] == 1) {
                            if (situation[1][13]) {
                                isRepeat[1][13] = true;
                            }
                            else {
                                situation[1][13] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 1 && dir[3] == 0) {
                            if (situation[1][14]) {
                                isRepeat[1][14] = true;
                            }
                            else {
                                situation[1][14] = true;
                            }
                        }
                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 1 && dir[3] == 1) {
                            if (situation[1][15]) {
                                isRepeat[1][15] = true;
                            }
                            else {
                                situation[1][15] = true;
                            }
                        }

                    }

                }
            }
            for (int i = 0; i < curGrids.length; i++) {
                for (int j = 0; j < curGrids[0].length; j++) {
                    int[] dir = {0, 0, 0, 0};
                    if (curGrids[i][j] == 3) {
                        //左方
                        for (int x = j - 1; x >= 0; x--) {
                            if (curGrids[i][x] == 3) {
                                dir[0] = 1;
                                break;
                            }
                        }

                        // 上方
                        for (int y = i - 1; y >= 0; y--) {
                            if (curGrids[y][j] == 3) {
                                dir[1] = 1;
                                break;
                            }
                        }

                        // 下方
                        for (int y = i + 1; y < curGrids.length; y++) {
                            if (curGrids[y][j] == 3) {
                                dir[2] = 1;
                                break;
                            }
                        }

                        // 右方
                        for (int x = j + 1; x < curGrids[i].length; x++) {
                            if (curGrids[i][x] == 3) {
                                dir[3] = 1;
                                break;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0 && dir[3] == 0) {
                            situation[0][0] = true;
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0 && dir[3] == 1) {
                            if (isRepeat[0][1]) {
                                signList.add(new TextSign(getIndex(i, j), "→", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "→", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1 && dir[3] == 0) {
                            if (isRepeat[0][2]) {
                                signList.add(new TextSign(getIndex(i, j), "↓", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "↓", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1 && dir[3] == 1) {
                            if (isRepeat[0][3]) {
                                signList.add(new TextSign(getIndex(i, j), "┌", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┌", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0 && dir[3] == 0) {
                            if (isRepeat[0][4]) {
                                signList.add(new TextSign(getIndex(i, j), "↑", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "↑", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0 && dir[3] == 1) {
                            if (isRepeat[0][5]) {
                                signList.add(new TextSign(getIndex(i, j), "└", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "└", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 1 && dir[3] == 0) {
                            if (isRepeat[0][6]) {
                                signList.add(new TextSign(getIndex(i, j), "↕", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "↕", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 1 && dir[3] == 1) {
                            if (isRepeat[0][7]) {
                                signList.add(new TextSign(getIndex(i, j), "├", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "├", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0 && dir[3] == 0) {
                            if (isRepeat[0][8]) {
                                signList.add(new TextSign(getIndex(i, j), "←", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "←", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0 && dir[3] == 1) {
                            if (isRepeat[0][9]) {
                                signList.add(new TextSign(getIndex(i, j), "↔", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "↔", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 1 && dir[3] == 0) {
                            if (isRepeat[0][10]) {
                                signList.add(new TextSign(getIndex(i, j), "┐", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┐", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 1 && dir[3] == 1) {
                            if (isRepeat[0][11]) {
                                signList.add(new TextSign(getIndex(i, j), "┬", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┬", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 0 && dir[3] == 0) {
                            if (isRepeat[0][12]) {
                                signList.add(new TextSign(getIndex(i, j), "┘", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┘", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 0 && dir[3] == 1) {
                            if (isRepeat[0][13]) {
                                signList.add(new TextSign(getIndex(i, j), "┴", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┴", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 1 && dir[3] == 0) {
                            if (isRepeat[0][14]) {
                                signList.add(new TextSign(getIndex(i, j), "┤", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┤", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 1 && dir[3] == 1) {
                            if (isRepeat[0][15]) {
                                signList.add(new TextSign(getIndex(i, j), "┼", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┼", "#FF000000"));
                            }
                        }
                    }
                    if (curGrids[i][j] == 4) {
                        //左方
                        for (int x = j - 1; x >= 0; x--) {
                            if (curGrids[i][x] == 4) {
                                dir[0] = 1;
                                break;
                            }
                        }

                        // 上方
                        for (int y = i - 1; y >= 0; y--) {
                            if (curGrids[y][j] == 4) {
                                dir[1] = 1;
                                break;
                            }
                        }

                        // 下方
                        for (int y = i + 1; y < curGrids.length; y++) {
                            if (curGrids[y][j] == 4) {
                                dir[2] = 1;
                                break;
                            }
                        }

                        // 右方
                        for (int x = j + 1; x < curGrids[i].length; x++) {
                            if (curGrids[i][x] == 4) {
                                dir[3] = 1;
                                break;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0 && dir[3] == 0) {
                            situation[1][0] = true;
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0 && dir[3] == 1) {
                            if (isRepeat[1][1]) {
                                signList.add(new TextSign(getIndex(i, j), "→", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "→", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1 && dir[3] == 0) {
                            if (isRepeat[1][2]) {
                                signList.add(new TextSign(getIndex(i, j), "↓", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "↓", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1 && dir[3] == 1) {
                            if (isRepeat[1][3]) {
                                signList.add(new TextSign(getIndex(i, j), "┌", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┌", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0 && dir[3] == 0) {
                            if (isRepeat[1][4]) {
                                signList.add(new TextSign(getIndex(i, j), "↑", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "↑", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0 && dir[3] == 1) {
                            if (isRepeat[1][5]) {
                                signList.add(new TextSign(getIndex(i, j), "└", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "└", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 1 && dir[3] == 0) {
                            if (isRepeat[1][6]) {
                                signList.add(new TextSign(getIndex(i, j), "↕", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "↕", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 1 && dir[3] == 1) {
                            if (isRepeat[1][7]) {
                                signList.add(new TextSign(getIndex(i, j), "├", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "├", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0 && dir[3] == 0) {
                            if (isRepeat[1][8]) {
                                signList.add(new TextSign(getIndex(i, j), "←", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "←", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0 && dir[3] == 1) {
                            if (isRepeat[1][9]) {
                                signList.add(new TextSign(getIndex(i, j), "↔", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "↔", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 1 && dir[3] == 0) {
                            if (isRepeat[1][10]) {
                                signList.add(new TextSign(getIndex(i, j), "┐", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┐", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 1 && dir[3] == 1) {
                            if (isRepeat[1][11]) {
                                signList.add(new TextSign(getIndex(i, j), "┬", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┬", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 0 && dir[3] == 0) {
                            if (isRepeat[1][12]) {
                                signList.add(new TextSign(getIndex(i, j), "┘", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┘", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 0 && dir[3] == 1) {
                            if (isRepeat[1][13]) {
                                signList.add(new TextSign(getIndex(i, j), "┴", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┴", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 1 && dir[3] == 0) {
                            if (isRepeat[1][14]) {
                                signList.add(new TextSign(getIndex(i, j), "┤", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┤", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 1 && dir[3] == 1) {
                            if (isRepeat[1][15]) {
                                signList.add(new TextSign(getIndex(i, j), "┼", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┼", "#FF000000"));
                            }
                        }


                    }

                }
            }
            blackScore = 0;
            whiteScore = 0;

            for (int i = 0; i < 2; i++) {
                for (boolean x : situation[i]) {
                    if (x) {
                        if (i == 0)
                            blackScore++;
                        else
                            whiteScore++;
                    }
                }
            }
        }
    }

    public void stillMove() {
//            clearBottoms();
        if (cur == 1) {
            noticeBlackMove();
        }
        else if (cur == 2) {
            noticeWhiteMove();
        }
    }

    private void changeMove() {
        clearBottoms();
        if (blueNum <= 0) {
            checkWin();
        }
        else {
            if (cur == 1) {
                noticeWhiteMove();
            }
            else if (cur == 2) {
                noticeBlackMove();
            }
        }
        lastPoint = new ArrayList<int[]>();
    }

    private class Rule1 implements Rule {

        @Override
        public void reset() {
//            originGrids = GridsUtils.createEmptyGrids(9, 9);
//            curGrids = GridsUtils.copyGrids(originGrids);
            curGrids[4][4] = 2;
            signList.clear();
            updateBoard(new ArrayList<>());
            blackNeutralNum = 5;
            whiteNeutralNum = 5;
            blackScore = 0;
            whiteScore = 0;
        }

        @Override
        public void getScore() {
            situation = new boolean[2][16];
            boolean[][] isRepeat = new boolean[2][16];
            for (int i = 0; i < curGrids.length; i++) {
                for (int j = 0; j < curGrids[0].length; j++) {
                    int[] dir = {0, 0, 0, 0};
                    if (curGrids[i][j] == 3) {
                        //左方
                        for (int x = j - 1; x >= 0; x--) {
                            if (curGrids[i][x] == 3) {
                                dir[0] = 1;
                                break;
                            }
                            else if (curGrids[i][x] == 2) {
                                break;
                            }
                        }

                        // 上方
                        for (int y = i - 1; y >= 0; y--) {
                            if (curGrids[y][j] == 3) {
                                dir[1] = 1;
                                break;
                            }
                            else if (curGrids[y][j] == 2) {
                                break;
                            }
                        }

                        // 下方
                        for (int y = i + 1; y < curGrids.length; y++) {
                            if (curGrids[y][j] == 3) {
                                dir[2] = 1;
                                break;
                            }
                            else if (curGrids[y][j] == 2) {
                                break;
                            }
                        }

                        // 右方
                        for (int x = j + 1; x < curGrids[i].length; x++) {
                            if (curGrids[i][x] == 3) {
                                dir[3] = 1;
                                break;
                            }
                            else if (curGrids[i][x] == 2) {
                                break;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0 && dir[3] == 0) {
                            situation[0][0] = true;
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0 && dir[3] == 1) {
                            if (situation[0][1]) {
                                isRepeat[0][1] = true;
                            }
                            else {
                                situation[0][1] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1 && dir[3] == 0) {
                            if (situation[0][2]) {
                                isRepeat[0][2] = true;
                            }
                            else {
                                situation[0][2] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1 && dir[3] == 1) {
                            if (situation[0][3]) {
                                isRepeat[0][3] = true;
                            }
                            else {
                                situation[0][3] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0 && dir[3] == 0) {
                            if (situation[0][4]) {
                                isRepeat[0][4] = true;
                            }
                            else {
                                situation[0][4] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0 && dir[3] == 1) {
                            if (situation[0][5]) {
                                isRepeat[0][5] = true;
                            }
                            else {
                                situation[0][5] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 1 && dir[3] == 0) {
                            if (situation[0][6]) {
                                isRepeat[0][6] = true;
                            }
                            else {
                                situation[0][6] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 1 && dir[3] == 1) {
                            if (situation[0][7]) {
                                isRepeat[0][7] = true;
                            }
                            else {
                                situation[0][7] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0 && dir[3] == 0) {
                            if (situation[0][8]) {
                                isRepeat[0][8] = true;
                            }
                            else {
                                situation[0][8] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0 && dir[3] == 1) {
                            if (situation[0][9]) {
                                isRepeat[0][9] = true;
                            }
                            else {
                                situation[0][9] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 1 && dir[3] == 0) {
                            if (situation[0][10]) {
                                isRepeat[0][10] = true;
                            }
                            else {
                                situation[0][10] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 1 && dir[3] == 1) {
                            if (situation[0][11]) {
                                isRepeat[0][11] = true;
                            }
                            else {
                                situation[0][11] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 0 && dir[3] == 0) {
                            if (situation[0][12]) {
                                isRepeat[0][12] = true;
                            }
                            else {
                                situation[0][12] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 0 && dir[3] == 1) {
                            if (situation[0][13]) {
                                isRepeat[0][13] = true;
                            }
                            else {
                                situation[0][13] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 1 && dir[3] == 0) {
                            if (situation[0][14]) {
                                isRepeat[0][14] = true;
                            }
                            else {
                                situation[0][14] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 1 && dir[3] == 1) {
                            if (situation[0][15]) {
                                isRepeat[0][15] = true;
                            }
                            else {
                                situation[0][15] = true;
                            }
                        }

                    }
                    if (curGrids[i][j] == 4) {
                        //左方
                        for (int x = j - 1; x >= 0; x--) {
                            if (curGrids[i][x] == 4) {
                                dir[0] = 1;
                                break;
                            }
                            else if (curGrids[i][x] == 2) {
                                break;
                            }
                        }

                        // 上方
                        for (int y = i - 1; y >= 0; y--) {
                            if (curGrids[y][j] == 4) {
                                dir[1] = 1;
                                break;
                            }
                            else if (curGrids[y][j] == 2) {
                                break;
                            }
                        }

                        // 下方
                        for (int y = i + 1; y < curGrids.length; y++) {
                            if (curGrids[y][j] == 4) {
                                dir[2] = 1;
                                break;
                            }
                            else if (curGrids[y][j] == 2) {
                                break;
                            }
                        }

                        // 右方
                        for (int x = j + 1; x < curGrids[i].length; x++) {
                            if (curGrids[i][x] == 4) {
                                dir[3] = 1;
                                break;
                            }
                            else if (curGrids[i][x] == 2) {
                                break;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0 && dir[3] == 0) {
                            situation[1][0] = true;
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0 && dir[3] == 1) {
                            if (situation[1][1]) {
                                isRepeat[1][1] = true;
                            }
                            else {
                                situation[1][1] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1 && dir[3] == 0) {
                            if (situation[1][2]) {
                                isRepeat[1][2] = true;
                            }
                            else {
                                situation[1][2] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1 && dir[3] == 1) {
                            if (situation[1][3]) {
                                isRepeat[1][3] = true;
                            }
                            else {
                                situation[1][3] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0 && dir[3] == 0) {
                            if (situation[1][4]) {
                                isRepeat[1][4] = true;
                            }
                            else {
                                situation[1][4] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0 && dir[3] == 1) {
                            if (situation[1][5]) {
                                isRepeat[1][5] = true;
                            }
                            else {
                                situation[1][5] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 1 && dir[3] == 0) {
                            if (situation[1][6]) {
                                isRepeat[1][6] = true;
                            }
                            else {
                                situation[1][6] = true;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 1 && dir[3] == 1) {
                            if (situation[1][7]) {
                                isRepeat[1][7] = true;
                            }
                            else {
                                situation[1][7] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0 && dir[3] == 0) {
                            if (situation[1][8]) {
                                isRepeat[1][8] = true;
                            }
                            else {
                                situation[1][8] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0 && dir[3] == 1) {
                            if (situation[1][9]) {
                                isRepeat[1][9] = true;
                            }
                            else {
                                situation[1][9] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 1 && dir[3] == 0) {
                            if (situation[1][10]) {
                                isRepeat[1][10] = true;
                            }
                            else {
                                situation[1][10] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 1 && dir[3] == 1) {
                            if (situation[1][11]) {
                                isRepeat[1][11] = true;
                            }
                            else {
                                situation[1][11] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 0 && dir[3] == 0) {
                            if (situation[1][12]) {
                                isRepeat[1][12] = true;
                            }
                            else {
                                situation[1][12] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 0 && dir[3] == 1) {
                            if (situation[1][13]) {
                                isRepeat[1][13] = true;
                            }
                            else {
                                situation[1][13] = true;
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 1 && dir[3] == 0) {
                            if (situation[1][14]) {
                                isRepeat[1][14] = true;
                            }
                            else {
                                situation[1][14] = true;
                            }
                        }
                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 1 && dir[3] == 1) {
                            if (situation[1][15]) {
                                isRepeat[1][15] = true;
                            }
                            else {
                                situation[1][15] = true;
                            }
                        }

                    }

                }
            }
            for (int i = 0; i < curGrids.length; i++) {
                for (int j = 0; j < curGrids[0].length; j++) {
                    int[] dir = {0, 0, 0, 0};
                    if (curGrids[i][j] == 3) {
                        //左方
                        for (int x = j - 1; x >= 0; x--) {
                            if (curGrids[i][x] == 3) {
                                dir[0] = 1;
                                break;
                            }
                            else if (curGrids[i][x] == 2) {
                                break;
                            }
                        }

                        // 上方
                        for (int y = i - 1; y >= 0; y--) {
                            if (curGrids[y][j] == 3) {
                                dir[1] = 1;
                                break;
                            }
                            else if (curGrids[y][j] == 2) {
                                break;
                            }
                        }

                        // 下方
                        for (int y = i + 1; y < curGrids.length; y++) {
                            if (curGrids[y][j] == 3) {
                                dir[2] = 1;
                                break;
                            }
                            else if (curGrids[y][j] == 2) {
                                break;
                            }
                        }

                        // 右方
                        for (int x = j + 1; x < curGrids[i].length; x++) {
                            if (curGrids[i][x] == 3) {
                                dir[3] = 1;
                                break;
                            }
                            else if (curGrids[i][x] == 2) {
                                break;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0 && dir[3] == 0) {
                            situation[0][0] = true;
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0 && dir[3] == 1) {
                            if (isRepeat[0][1]) {
                                signList.add(new TextSign(getIndex(i, j), "→", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "→", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1 && dir[3] == 0) {
                            if (isRepeat[0][2]) {
                                signList.add(new TextSign(getIndex(i, j), "↓", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "↓", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1 && dir[3] == 1) {
                            if (isRepeat[0][3]) {
                                signList.add(new TextSign(getIndex(i, j), "┌", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┌", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0 && dir[3] == 0) {
                            if (isRepeat[0][4]) {
                                signList.add(new TextSign(getIndex(i, j), "↑", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "↑", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0 && dir[3] == 1) {
                            if (isRepeat[0][5]) {
                                signList.add(new TextSign(getIndex(i, j), "└", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "└", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 1 && dir[3] == 0) {
                            if (isRepeat[0][6]) {
                                signList.add(new TextSign(getIndex(i, j), "↕", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "↕", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 1 && dir[3] == 1) {
                            if (isRepeat[0][7]) {
                                signList.add(new TextSign(getIndex(i, j), "├", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "├", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0 && dir[3] == 0) {
                            if (isRepeat[0][8]) {
                                signList.add(new TextSign(getIndex(i, j), "←", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "←", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0 && dir[3] == 1) {
                            if (isRepeat[0][9]) {
                                signList.add(new TextSign(getIndex(i, j), "↔", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "↔", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 1 && dir[3] == 0) {
                            if (isRepeat[0][10]) {
                                signList.add(new TextSign(getIndex(i, j), "┐", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┐", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 1 && dir[3] == 1) {
                            if (isRepeat[0][11]) {
                                signList.add(new TextSign(getIndex(i, j), "┬", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┬", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 0 && dir[3] == 0) {
                            if (isRepeat[0][12]) {
                                signList.add(new TextSign(getIndex(i, j), "┘", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┘", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 0 && dir[3] == 1) {
                            if (isRepeat[0][13]) {
                                signList.add(new TextSign(getIndex(i, j), "┴", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┴", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 1 && dir[3] == 0) {
                            if (isRepeat[0][14]) {
                                signList.add(new TextSign(getIndex(i, j), "┤", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┤", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 1 && dir[3] == 1) {
                            if (isRepeat[0][15]) {
                                signList.add(new TextSign(getIndex(i, j), "┼", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┼", "#FF000000"));
                            }
                        }
                    }
                    if (curGrids[i][j] == 4) {
                        //左方
                        for (int x = j - 1; x >= 0; x--) {
                            if (curGrids[i][x] == 4) {
                                dir[0] = 1;
                                break;
                            }
                            else if (curGrids[i][x] == 2) {
                                break;
                            }
                        }

                        // 上方
                        for (int y = i - 1; y >= 0; y--) {
                            if (curGrids[y][j] == 4) {
                                dir[1] = 1;
                                break;
                            }
                            else if (curGrids[y][j] == 2) {
                                break;
                            }
                        }

                        // 下方
                        for (int y = i + 1; y < curGrids.length; y++) {
                            if (curGrids[y][j] == 4) {
                                dir[2] = 1;
                                break;
                            }
                            else if (curGrids[y][j] == 2) {
                                break;
                            }
                        }

                        // 右方
                        for (int x = j + 1; x < curGrids[i].length; x++) {
                            if (curGrids[i][x] == 4) {
                                dir[3] = 1;
                                break;
                            }
                            else if (curGrids[i][x] == 2) {
                                break;
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0 && dir[3] == 0) {
                            situation[1][0] = true;
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 0 && dir[3] == 1) {
                            if (isRepeat[1][1]) {
                                signList.add(new TextSign(getIndex(i, j), "→", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "→", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1 && dir[3] == 0) {
                            if (isRepeat[1][2]) {
                                signList.add(new TextSign(getIndex(i, j), "↓", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "↓", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1 && dir[3] == 1) {
                            if (isRepeat[1][3]) {
                                signList.add(new TextSign(getIndex(i, j), "┌", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┌", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0 && dir[3] == 0) {
                            if (isRepeat[1][4]) {
                                signList.add(new TextSign(getIndex(i, j), "↑", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "↑", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0 && dir[3] == 1) {
                            if (isRepeat[1][5]) {
                                signList.add(new TextSign(getIndex(i, j), "└", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "└", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 1 && dir[3] == 0) {
                            if (isRepeat[1][6]) {
                                signList.add(new TextSign(getIndex(i, j), "↕", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "↕", "#FF000000"));
                            }
                        }

                        if (dir[0] == 0 && dir[1] == 1 && dir[2] == 1 && dir[3] == 1) {
                            if (isRepeat[1][7]) {
                                signList.add(new TextSign(getIndex(i, j), "├", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "├", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0 && dir[3] == 0) {
                            if (isRepeat[1][8]) {
                                signList.add(new TextSign(getIndex(i, j), "←", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "←", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0 && dir[3] == 1) {
                            if (isRepeat[1][9]) {
                                signList.add(new TextSign(getIndex(i, j), "↔", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "↔", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 1 && dir[3] == 0) {
                            if (isRepeat[1][10]) {
                                signList.add(new TextSign(getIndex(i, j), "┐", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┐", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 0 && dir[2] == 1 && dir[3] == 1) {
                            if (isRepeat[1][11]) {
                                signList.add(new TextSign(getIndex(i, j), "┬", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┬", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 0 && dir[3] == 0) {
                            if (isRepeat[1][12]) {
                                signList.add(new TextSign(getIndex(i, j), "┘", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┘", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 0 && dir[3] == 1) {
                            if (isRepeat[1][13]) {
                                signList.add(new TextSign(getIndex(i, j), "┴", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┴", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 1 && dir[3] == 0) {
                            if (isRepeat[1][14]) {
                                signList.add(new TextSign(getIndex(i, j), "┤", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┤", "#FF000000"));
                            }
                        }

                        if (dir[0] == 1 && dir[1] == 1 && dir[2] == 1 && dir[3] == 1) {
                            if (isRepeat[1][15]) {
                                signList.add(new TextSign(getIndex(i, j), "┼", "#FFFFFFFF"));
                            }
                            else {
                                signList.add(new TextSign(getIndex(i, j), "┼", "#FF000000"));
                            }
                        }


                    }

                }
            }
            blackScore = 0;
            whiteScore = 0;

            for (int i = 0; i < 2; i++) {
                for (boolean x : situation[i]) {
                    if (x) {
                        if (i == 0)
                            blackScore++;
                        else
                            whiteScore++;
                    }
                }
            }
        }


    }

    private void checkWin() {
        clearBottoms();
        rule.getScore();
        if (blackScore > whiteScore) {
            doOver(WinMode.BLACK_WIN, player_black.getNickNameOrTemp() + "战胜" + player_white.getNickNameOrTemp());
        }
        else if (blackScore < whiteScore) {
            doOver(WinMode.WHITE_WIN, player_white.getNickNameOrTemp() + "战胜" + player_black.getNickNameOrTemp());
        }
        else {
            if (blackNeutralNum > whiteNeutralNum) {
                doOver(WinMode.BLACK_WIN, player_black.getNickNameOrTemp() + "战胜" + player_white.getNickNameOrTemp());
            }
            else if (blackNeutralNum < whiteNeutralNum) {
                doOver(WinMode.WHITE_WIN, player_white.getNickNameOrTemp() + "战胜" + player_black.getNickNameOrTemp());
            }
            doOver(WinMode.BOTH_DRAW, player_black.getNickNameOrTemp() + "-黑棋战平" + player_white.getNickNameOrTemp() + "-白棋");
        }
    }

    CustomBottom cb_cancelPut = new CustomBottom(this, "不放", (player) -> {
        changeMove();
        isNeutral = false;
        neutralState = 0;
//        noClock = true;
    });
    CustomBottom cb_changeMode = new CustomBottom(this, "切换模式", (player) -> {
        if (step > 0) {
            return;
        }
        curMode++;
        curMode = curMode % 2;
        if (curMode == 0) {
            rule = new Rule0();
            gameTip = "当前启用基础规则";
        }
        else if (curMode == 1) {
            rule = new Rule1();
            gameTip = "当前启用进阶规则";
        }
        rule.reset();
        noticeBlackMove();
    });

    public StarsZoneAiRoom(String roomName) {
        super(roomName, "\t\t\t\t某猪设计的棋，obli写的ai。", "星域Ai版", BoardStyleData.getGoBangStyle(9, 9), false, false, "默认", "比赛");
        rule.reset();
    }

    @Override
    public String getRuleText() {
        return "【游戏提示】\n" +
                "第一次点击落下红/蓝子，之后可选择点击按钮不放跳过回合，或者继续点击棋盘来落下中立棋子\n" +
                "\n" +
                "一 棋具\n" +
                "使用如右图所示的棋盘。使用红色、蓝色\n" +
                "棋子各 16 枚，白色棋子至多 17 枚。\n" +
                "棋子落在棋盘交叉点上，坐标为 2 个 1~9\n" +
                "的整数，先行后列。\n" +
                "二 初始设置\n" +
                "双方分别取全部红色、蓝色棋子，称为己\n" +
                "方棋子（或对方棋子）；然后每方取 5~8 枚白色棋子，称为中立棋子。\n" +
                "使用基础规则（见下）时建议每方取 7 枚中立棋子，" +
                "使用进阶规则时建议取 5 枚。棋手水平较高或使用辅助软件时，应适当增加数量。\n" +
                "最后，将 1 枚中立棋子放置到坐标 (5,5) 处。\n" +
                "三 对局\n" +
                "红先蓝后，双方轮流行动。每回合，放置 1 枚己方棋子至棋盘空位，\n" +
                "随后可以再放置 1 枚己方中立棋子至棋盘空位。\n" +
                "己方棋子用尽后（即第 16 回合结束后），游戏结束，进行计分。\n" +
                "四 计分与胜负\n" +
                "计分方式如下：对于每方的 16 枚己方棋子，观察其上、下、左、右\n" +
                "四个方向上是否有其它己方棋子。对方棋子不会阻挡观察视线，且\n" +
                "基础规则：中立棋子不会阻挡观察视线。\n" +
                "进阶规则：中立棋子会阻挡观察视线。\n" +
                "共有 16 种可能情况（例如“上有、右有、下无、左无”为一种情况，“上无、右\n" +
                "有、下有、左无”为另一种），每种出现的情况计 1 分。\n" +
                "分数高的一方获胜。若分数相同，则剩余中立棋子多的一方获胜。";
    }

    @Override
    public void doStart() {
        overFlag = 1;//重置结束状态：对弈进行中未结束
        playingStartTime = System.currentTimeMillis(); //重置对弈开始时间
        rule.reset();
        /*if (player_black != null) {
            player_black.registerCustomBottom(cb_changeMode);
        }
        if (player_white != null) {
            player_white.registerCustomBottom(cb_changeMode);
        }*/
        DataManager.noticeAllGameStart(player_black, player_white, roomName);
        gameTip = "当前启用基础规则";
        noticeBlackMove();
        preHistory();
    }

    @Override
    public void resetGrids() {
        step = 0;
        gameTip = "-1";
        clearBottoms();
        rule = new Rule0();
        rule.reset();
        curGrids = GridsUtils.copyGrids(originGrids);
        curGrids[4][4] = 2;
        lastPoint = new ArrayList<int[]>();
//        noClock = true;
        blackScore = 0;
        whiteScore = 0;
        blackNeutralNum = isCurMode("比赛") ? 8 : 7;
        whiteNeutralNum = isCurMode("比赛") ? 8 : 7;
        blueNum = 16;
        redNum = 16;
        curMode = 0;
        isNeutral = false;
        neutralState = 0;

    }

    @Override
    public void doRule(int row, int col, int value) {
        if (banPosition[row][col] == 1) {
            if (curGrids[row][col] == 0) { //落子在有效棋盘范围内时
                if (step == 0) { //初步落子清空所有提示和按钮
                    clearBottoms();
                    gameTip = "-1";
                }
                //落下非中立棋子
                if (!isNeutral) {
                    step++;
                    curGrids[row][col] = value == BLACK_CUR ? 3 : 4;
                    if (cur == 1) {
                        redNum--;
                    }
                    else if (cur == 2) {
                        blueNum--;
                    }
                    lastPoint.add(new int[]{row, col});
                    if ((value == BLACK_CUR ? blackNeutralNum : whiteNeutralNum) > 0) {
                        if (value == BLACK_CUR) {
                            player_black.registerCustomBottom(cb_cancelPut);
                            neutralState = 1;
                        }
                        else if (value == WHITE_CUR) {
                            player_white.registerCustomBottom(cb_cancelPut);
                            neutralState = 2;
                        }
                        isNeutral = true;

                    }
                    else {
                        addHistory(cur == 1 ? "黑方红子落在" : "白方蓝子落在" + (row + 1) + "行" + (col + 1) + "列"); //添加战报记录
                        changeMove();
                        isNeutral = false;
                    }
                    noticeAllRefreshGameInfo();
                }
                //落下中立棋子
                else {
                    neutralState = 0;
                    curGrids[row][col] = 2;
                    if (cur == 1) {
                        blackNeutralNum--;
                    }
                    else if (cur == 2) {
                        whiteNeutralNum--;
                    }
                    isNeutral = false;
                    lastPoint.add(new int[]{row, col});

                    addHistory(cur == 1 ? "黑方白子落在" : "白方白子落在" + (row + 1) + "行" + (col + 1) + "列"); //添加战报记录
                    changeMove();
                }
            }
        }
    }


    // 落座后自动找机器人下棋
    @Override
    public void setBlackPlayer(Player player) {
        super.setBlackPlayer(player);
        if (player_white == null) {
            setWhitePlayer(createRobotPlayer()); //黑方上座时，白方自动上座机器人
        }
        if (neutralState == 1) {
            player_black.registerCustomBottom(cb_cancelPut);
        }
    }

    // 落座后自动找机器人下棋
    @Override
    public void setWhitePlayer(Player player) {
        super.setWhitePlayer(player);
        if (player_black == null) {
            setBlackPlayer(createRobotPlayer()); //白方上座时，黑方自动上座机器人
        }
        if (neutralState == 2) {
            player_white.registerCustomBottom(cb_cancelPut);
        }
    }

    // 创建陪玩的ai机器人
    @Override
    protected RobotPlayer createRobotPlayer() {
        String[] names = {"#搜寻者", "#执律者", "#裁决者"};
        String name;
        int level;
        int rdm = (int) (Math.random() * 6);
        if (rdm < 3){
            name = names[0];
            level = 1;
        }
        else if (rdm < 5){
            name = names[1];
            level = 2;
        }
        else {
            name = names[2];
            level = 3;
        }
        return new RobotPlayer(this, "obli1234zqai", name, () -> {
            int[][] board = GridsUtils.copyGrids(curGrids);
            for (int i = 0; i < board.length; i++) {
                for (int j = 0; j < board[0].length; j++) {
                    if (banPosition[i][j] == 0) {
                        board[i][j] = 3; //不能落子处转换
                    }
                    else if (board[i][j] == 0) {
                        board[i][j] = 0; //空位转换
                    }
                    else if (board[i][j] == 2) {
                        board[i][j] = 2; //白子
                    }
                    else if (board[i][j] == 3) {
                        board[i][j] = 1; //红子
                    }
                    else if (board[i][j] == 4) {
                        board[i][j] = -1; //蓝子
                    }
                }
            }
            int playerTurn = (cur == 1 ? 1 : -1);  //当前行动方  1：黑方红子    2：白方蓝子
            int remainWhiteNum = (cur == 1 ? blackNeutralNum : whiteNeutralNum); //剩余白子数量
            int difficulty = level + 1; //难度 1-3级

            //得到的结果
            int[] point = StarZoneEngine.starZoneEngine(board, playerTurn, remainWhiteNum, difficulty);

            Player player = playerTurn == 1 ? player_black : player_white;
            int row = point[0] - 1;
            int col = point[1] - 1;
            sleep(250);
            moveLater(player, row, col);
            sleep(250);
            if (point[3] == 0){ //不落白子
                if (player.findCustomBottomByTitle(this, "不放") != null){
                    changeMove();
                    isNeutral = false;
                    neutralState = 0;
                }
            }
            else { //落下白子
                int nRow = point[2] - 1;
                int nCol = point[3] - 1;
                moveLater(player, nRow, nCol);
            }
        });
    }

    private void updateBoard(List<Sign> tmpSignList) {
//        curGrids = GridsUtils.copyGrids(originGrids);
        signList.clear(); //清除旧记号
        signList.add(new GroundSign(getIndex(0, 0), getIndex(curGrids.length - 1, curGrids[0].length - 1), "#FF00007F", "#FF3388FF", 1.8f, 0, 0));
        List<Pair<Integer, Integer>> nodes1 = new ArrayList<>();
        nodes1.add(new Pair<>(getIndex(0, 3), 4));
        nodes1.add(new Pair<>(getIndex(3, 0), 4));
        nodes1.add(new Pair<>(getIndex(7, 1), 4));
        nodes1.add(new Pair<>(getIndex(8, 5), 4));
        nodes1.add(new Pair<>(getIndex(5, 8), 4));
        nodes1.add(new Pair<>(getIndex(1, 7), 4));
        nodes1.add(new Pair<>(getIndex(0, 3), 4));

        signList.add(new PathSign(nodes1, "#FFFFFF00", "#FF010280", 1f, 1));

//        getPathSign(0,3,0,4);
        getPathSign(0, 3, 0, 4);
        getPathSign(1, 2, 1, 7);
        getPathSign(2, 1, 2, 7);
        getPathSign(3, 0, 3, 7);
        getPathSign(4, 0, 4, 8);
        getPathSign(5, 1, 5, 8);
        getPathSign(6, 1, 6, 7);
        getPathSign(7, 1, 7, 6);
        getPathSign(8, 4, 8, 5);
        getPathSign(3, 0, 4, 0);
        getPathSign(2, 1, 7, 1);
        getPathSign(1, 2, 7, 2);
        getPathSign(0, 3, 7, 3);
        getPathSign(0, 4, 8, 4);
        getPathSign(1, 5, 8, 5);
        getPathSign(1, 6, 7, 6);
        getPathSign(1, 7, 6, 7);
        getPathSign(4, 8, 5, 8);

        if (player_black == null && player_white == null) {
            signList.add(new TitleSign(0.5f, 0.45f, 0, "Stars' Zone", "#FFAA0000", 1.1f));
//            signList.add(new TitleSign(0.07f, 0.05f, 0, "7", "#FFAA0000", 0.6f));
//            signList.add(new TitleSign(0.95f, 0.05f, 0, "7", "#FFAA0000", 0.6f));
        }
        signList.addAll(tmpSignList);
    }


    private void getPathSign(int FRow, int FCol, int SRow, int SCol) {
        List<Pair<Integer, Integer>> nodes = new ArrayList<>();
        nodes.add(new Pair<>(getIndex(FRow, FCol), 4));
        nodes.add(new Pair<>(getIndex(SRow, SCol), 4));
        signList.add(new PathSign(nodes, "#FFFFFF00", "#FFFFFF00", 1f, 0));
    }

    private void clearBottoms() {
        if (player_black != null) {
            if (player_black.findCustomBottomByTitle(this, "切换模式") != null
                    || player_black.findCustomBottomByTitle(this, "不放") != null
                    || player_black.findCustomBottomByTitle(this, "放置中立棋子") != null) {
                player_black.clearCustomBottom();
                player_black.dispatchCustomBottom();
            }
        }
        if (player_white != null) {
            if (player_white.findCustomBottomByTitle(this, "切换模式") != null
                    || player_white.findCustomBottomByTitle(this, "不放") != null
                    || player_white.findCustomBottomByTitle(this, "放置中立棋子") != null) {
                player_white.clearCustomBottom();
                player_white.dispatchCustomBottom();
            }
        }
    }

}